
****************************************************************
************ Reset 
****************************************************************

clear 
set more off


****************************************************************
************ Set Options 
****************************************************************

* List of dedup numbers 
global dedup_options `" "6" "10"' 



****************************************************************
************ Loop through matches 
****************************************************************

****** Match 1 

* Reset 
clear
set more off

* Set match option 
global match_num "1" 

* Run analysis for each dedup option 
foreach i of global dedup_options {
	global dedup_num `i'
	****** Other file name vars 
	global date "4-13_" 
	global suffix ".dta"
	global match "m${match_num}_"
	global dedup "dedup${dedup_num}"
	****** Initial R dataset location vars 
	global filenameR "comb_tfa_matches_"
	global datafilepath "Temp_Data/"
	****** Saved stata dataset location var 
	global filenameS "comb_tfa_matches_clean_merge_"
	****** Load .dta file exported from R
	di "${datafilepath}${date}${filenameR}${match}${dedup}${suffix}"
	use "${datafilepath}${date}${filenameR}${match}${dedup}${suffix}" ,clear
	destring appyear, replace
	destring matriculated4, replace
	destring corpsyear, replace
	****** Run file with data prep code 
	do "114_prepdata", nostop
	****** Save data as .dta
	di "${datafilepath}${date}${filenameS}${match}${dedup}${suffix}" //check filepath
	save "${datafilepath}${date}${filenameS}${match}${dedup}${suffix}" ,replace
	****** Save data as .csv
	export delimited zscore ever_vote_* prop_vote_* appyear personid admit vf_match_state_* matriculated4 not_registered registered* state* uscitizen ///
		using "${datafilepath}${date}${filenameS}${match}${dedup}", replace
	****** Print message to screen 
	di in red "Completed data cleaning and saved cleaned data for match ${match_num}, dedup ${dedup_num}"
} 
*
